package com.coolbi.onsupai.core.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;

import com.coolbi.onsupai.core.dao.InvoiceDao;
import com.coolbi.onsupai.core.entity.Invoice;
import com.coolbi.onsupai.core.mapper.InvoiceMapper;

public class InvoiceDaoImpl implements InvoiceDao {

	@Autowired
	private InvoiceMapper invoiceMapper;
	public void setInvoiceMapper(InvoiceMapper invoiceMapper) {
		this.invoiceMapper = invoiceMapper;
	}
	
	@Override
	public Invoice save(Invoice obj) {
		invoiceMapper.save(obj);
		return obj;
	}

	@Override
	public int delete(long id) {
		return invoiceMapper.delete(id);
	}

	@Override
	public int update(Invoice obj) {
		return invoiceMapper.update(obj);
	}

	@Override
	public Invoice get(long id) {
		return invoiceMapper.get(id);
	}

	@Override
	public List<Invoice> list() {
		return invoiceMapper.list();
	}

	@Override
	public List<Invoice> listByPage(int offset, int limit) {
		Map<String, Object> parameter = new HashMap<String, Object>();
		parameter.put("offset", offset);
		parameter.put("limit", limit);
		return invoiceMapper.listByPage(parameter);
	}

	@Override
	public List<Invoice> find(Map<String, Object> parameter) {
		return invoiceMapper.listByParameter(parameter);
	}

	@Override
	public List<Invoice> findByPage(Map<String, Object> parameter, int offset,
			int limit) {
		parameter.put("offset", offset);
		parameter.put("limit", limit);
		return invoiceMapper.listByParameterPage(parameter);
	}

	@Override
	public List<Invoice> search(Map<String, Object> parameter, int offset,
			int limit) {
		parameter.put("offset", offset);
		parameter.put("limit", limit);
		return invoiceMapper.search(parameter);
	}

	@Override
	public int count() {
		return invoiceMapper.count();
	}

	@Override
	public int countByKeyWord(Map<String, Object> parameter) {
		return invoiceMapper.countByKeyWord(parameter);
	}

	@Override
	public int count(Map<String, Object> parameter) {
		return invoiceMapper.countByParameter(parameter);
	}

}
